import 'package:dio/dio.dart';
import 'package:flutter_boss_mine/eneity/position_entity.dart';
import 'package:flutter_boss_mine/http/api_response.dart';
import 'package:flutter_boss_mine/http/http_utils.dart';

class PositionRepository {
  static final String positions = "/position";
  static Future<ApiResponse<PositionEntity>> getPositions(int page, int pageSize) async {

    try {
      final response = await HttpUtils.get(positions, params: {"page": page, "pageSize":pageSize});
      var data = PositionEntity().fromJson(response);
      return ApiResponse.completed(data);
    } on DioError catch (e) {
      return ApiResponse.error(e.error);
    }
  }
}